import ajax from '../util/ajax'
var html = document.documentElement
const layout = html.clientWidth || document.body.clientWidth;
html.style.fontSize = layout / 3.75 + 'px';
var cs = location.search
var pageId = cs.slice(cs.indexOf('=') + 1)
ajax('http://39.106.114.31:8080/good' + pageId).then((data) => {
  $.each(data, (key, value) => {
    $('.goodList').append(`
    <a href=./goodDetail.html?id=${value.gid}><li class=goodDetail>
    <img src=${value.url} class=goodImg>
    <p class=goodName>${value.name}</p>
    <p class=goodPrice>￥${value.price}.00</p>
    </li></a>
    `)
    sessionStorage.setItem(value.gid, JSON.stringify(value))
  })
}, (error) => {
  return new Error(error)
})